[Home]
[Chapter]
[Contents]
[Previous Algorithm]
[Next Algorithm]


Linear probing hashing: search


function search( key : typekey; var r : dataarray ) : integer; var i, last : integer; begin i := hashfunction( key ) ; last := (i+n-1) mod m; while (i<>last) and (not empty(r[i])) and (r[i].k<>key) do i := (i+1) mod m; if r[i].k=key then search := i {*** found(r[i]) ***} else search := -1; {*** notfound(key) ***} end;

C source (334.srch.c) Pascal source (334.srch.p)



© Addison-Wesley Publishing Co. Inc.